<?php
	require_once 'environment.php';
	$temp->addSubMenu("Future Goals", "future.html");
	if($acc->isLogged()) {
		$temp->addSubMenu("Edit About Us", "aboutUs.php?where=editUs");
		$temp->addSubMenu("Edit Future Goals", "aboutUs.php?where=editFuture");
	}
	
	$where = fixArr($_GET, "where");
	
	switch($where) {
		default:
			$temp->setTab(7);
			$temp->currentPage("Home >> About Us");
			$temp->generate();
			$sql = $db->Execute("SELECT * FROM `monster`.`frontPage` WHERE `AutoInc` = ? LIMIT 1", array(4));
			if($sql->RecordCount() == 1) {
				$row = $sql->FetchRow();
				print nl2br($row['Text']);
			}else {
				print "There seems to be a connection issue at this time.<br />\nPlease alert the administrator for more information.";
			}
			break;
		case("future"):
			$temp->setTab(7, 0);
			$temp->currentPage("Home >> About Us >> Future Goals");
			$temp->generate();
			$sql = $db->Execute("SELECT * FROM `monster`.`frontPage` WHERE `AutoInc` = ? LIMIT 1", array(5));
			if($sql->RecordCount() == 1) {
				$row = $sql->FetchRow();
				print nl2br($row['Text']);
			}else{
				print "There seems to be a connection issue at this time.<br />\nPlease alert the administrator for more information.";
			}
			break;
		case("editUs"):
			if(!$acc->isLogged()) die(change_site("account.php"));
			$temp->setTab(7, 1);
			$temp->currentPage("Home >> About Us >> Edit About Us");
			$temp->generate();
			if(!fixArr($_POST, "change")) {
				$sql = $db->Execute("SELECT * FROM `monster`.`frontPage` WHERE `AutoInc` = ? LIMIT 1", array(4));
				if($sql->RecordCount() == 1) {
					$row = $sql->FetchRow();
					print "<form action=\"\" method=\"POST\">\n";
					print "<textarea name=\"change\" style=\"resize: none;\" rows=\"20\" cols=\"60\">{$row['Text']}</textarea><br />\n";
					print "<input type=\"submit\" value=\"Change\" /> <input type=\"reset\" value=\"Reset\" />\n";
					print "</form>\n";
				}else {
					die("Sorry, we have encountered an connection error.<br />\nPlease try again later.");
				}
			}else {
				$change = stripslashes(fixArr($_POST, "change"));
				$db->Execute("UPDATE `monster`.`frontPage` SET `Text` = ? WHERE `AutoInc` = ? LIMIT 1", array($change, 4));
				$acc->adminGPS("Changed about us page.");
                print "The About Us page has been changed successfully.";
			}
			break;
		case("editFuture"):
			if(!$acc->isLogged()) die(change_site("account.php"));
			$temp->setTab(7, 2);
			$temp->currentPage("Home >> About Us >> Edit Future Goals");
			$temp->generate();
			if(!fixArr($_POST, "change")) {
				$sql = $db->Execute("SELECT * FROM `monster`.`frontPage` WHERE `AutoInc` = ? LIMIT 1", array(5));
				if($sql->RecordCount() == 1) {
					$row = $sql->FetchRow();
					print "<form action=\"\" method=\"POST\">\n";
					print "<textarea name=\"change\" style=\"resize: none;\" rows=\"20\" cols=\"60\">{$row['Text']}</textarea><br />\n";
					print "<input type=\"submit\" value=\"Change\" /> <input type=\"reset\" value=\"Reset\" />\n";
					print "</form>\n";
				}else {
					die("Sorry, we have encountered a connection error.<br />\nPlease try again later.");
				}
			}else {
				$change = stripslashes(fixArr($_POST, "change"));
				$db->Execute("UPDATE `monster`.`frontPage` SET `Text` = ? WHERE `AutoInc` = ? LIMIT 1", array($change, 5));
				$acc->adminGPS("Changed future goals page.");
                print "The Future Goals page has been changed uccessfully.";
			}
			break;
	}
?>